package com.loeng.module.system.dal.mysql.auth;

import com.loeng.framework.mybatis.core.mapper.BaseMapperX;
import com.loeng.module.system.dal.dataobject.oauth2.OAuth2RefreshTokenDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * OAuth2RefreshTokenMapper
 * @author loeng zhuo
 */
@Mapper
public interface OAuth2RefreshTokenMapper extends BaseMapperX<OAuth2RefreshTokenDO> {

    /**
     * 根据刷新令牌，获取刷新令牌
     *
     * @param accessToken 访问令牌
     * @return 刷新令牌
     */
    default OAuth2RefreshTokenDO selectByRefreshToken(String accessToken) {
        return selectOne(OAuth2RefreshTokenDO::getRefreshToken, accessToken);
    }

    /**
     * 删除刷新令牌
     *
     * @param refreshToken 刷新令牌
     */
    default int deleteByRefreshToken(String refreshToken) {
        return delete(OAuth2RefreshTokenDO::getRefreshToken, refreshToken);
    }

}
